/*
 * PWM.c
 *
 * Created: 11/15/2012 6:33:05 PM
 *  Author: Hp-Minion
 */ 
/*****************************************************************************************/
#include <avr/io.h>
#include "General.h"
#include "Port.h"
#include "PWM.h"
#include "Timer.h"
/*****************************************************************************************/
volatile unsigned int solution = 0;
volatile unsigned int sol = 0;
/*****************************************************************************************/
void PWM_vInit(void)
{
	//Timer0_vStartTimer1AsPWM();
	TCNT1 = 0;
	OCR1B = 0;
}	
/*****************************************************************************************/
void PWM_vHandler(void)
{
	switch (solution)
	{
		case 0:	{
					sol++;
					if (sol == DUTY_PRESCALER)
					{
						OCR1B += DUTY_PASS;
						sol = 0;
					}
				}				
		break;
		
		case 1:	OCR1B = TOP_DUTY;
		break;
		
		case 2:	{
					sol++;
					if (sol == DUTY_PRESCALER)
					{
						OCR1B -= DUTY_PASS;
						sol = 0;
					}
				}				
		break;
		
		case 3:	OCR1B = BOTTOM_DUTY;
		break;
	}
}			
/*****************************************************************************************/
